#include <iostream>
#include <vector>
#include <climits>
using namespace std;

class Gloves {
public:
    int findMinimum(int n, vector<int> left, vector<int> right) {
        int left_sum = 0;
        int left_min = INT_MAX;
        
        int right_sum = 0;
        int right_min = INT_MAX;

        int sum = 0;
        for(size_t i = 0; i < n; i++)
        {
            if(left[i] * right[i] == 0)
            {
                sum += left[i] + right[i];
            }
            else 
            {
                left_sum += left[i];
                left_min = left_min < left[i] ? left_min : left[i];

                right_sum += right[i];
                right_min = right_min < right[i] ? right_min : right[i];
            }
        }

        return sum + min(left_sum - left_min + 1, right_sum - right_min + 1) + 1;
    }

};